package com.gsm.jsp.controller;

import com.gsm.jsp.model.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by lijs on 16-7-10.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping(value = "/getuser/{id}",method = RequestMethod.GET)
    public ModelAndView getUser(@PathVariable("id") Integer id) {

        ModelAndView mv = new ModelAndView();

        Person p = new Person();
        p.setName("lijs");
        p.setAddr("addr");
        p.setAge(30);

        mv.addObject("p", p);
        mv.setViewName("hello");
        return mv;
    }


    @RequestMapping(value = "/g",method = RequestMethod.GET)
    public @ResponseBody Person g() {
        Person p = new Person();
        p.setName("lijs");
        p.setAddr("addr");
        p.setAge(30);
        return p;
    }

}
